package com.wm.yigongfang.common.web;

/**
 * @author zhangPeng
 * @description
 * @date 2021/4/20 11:07
 */
public class Results {
  /**
   * 200
   */
  public static Result ok() {
    return ok("");
  }

  /**
   * 200
   */
  public static Result ok(String msg) {
    return ok(msg, null);
  }

  /**
   * 200
   *
   * @param data
   * @return
   */
  public static Result ok(Object data) {
    return ok("", data);
  }


  /**
   * 200
   */
  public static Result ok(String msg, Object data) {
    Result result = new Result(ResultCode.SUCCESS.code, msg, data);
    return result;
  }


  /**
   * 201
   */
  public static Result created() {
    return created("");
  }

  /**
   * 201
   */
  public static Result created(String msg) {
    return created(msg, null);
  }

  /**
   * 201
   *
   * @param data
   * @return
   */
  public static Result created(Object data) {
    return created("", data);
  }

  /**
   * 201
   */
  public static Result created(String msg, Object data) {
    Result result = new Result(ResultCode.CREATED.code, msg, data);
    return result;
  }

  /**
   * 400
   */
  public static Result fail() {
    return fail("");
  }

  /**
   * 400
   */
  public static Result fail(String msg) {
    return fail(msg, 0);
  }

  /**
   * 400
   */
  public static Result fail(String msg, long totalCount) {
    Result result = new Result(ResultCode.FAIL.code, msg, null);
    return result;
  }

  /**
   * 401
   */
  public static Result unauthorized() {
    return unauthorized("");
  }

  /**
   * 401
   */
  public static Result unauthorized(String msg) {
    return unauthorized(msg, 0);
  }

  /**
   * 401
   */
  public static Result unauthorized(String msg, long totalCount) {
    Result result = new Result(ResultCode.UNAUTHORIZED.code, msg, null);
    return result;
  }

  /**
   * 403
   */
  public static Result forbidden() {
    return forbidden("");
  }

  /**
   * 403
   */
  public static Result forbidden(String msg) {
    return forbidden(msg, 0);
  }

  /**
   * 403
   */
  public static Result forbidden(String msg, long totalCount) {
    Result result = new Result(ResultCode.FORBIDDEN.code, msg, null);
    return result;
  }
  /**
   * 404
   */
  public static Result notFound() {
    return notFound("");
  }

  /**
   * 404
   */
  public static Result notFound(String msg) {
    return notFound(msg, 0);
  }

  /**
   * 404
   */
  public static Result notFound(Object data) {
    return notFound("", data);
  }

  /**
   * 404
   */
  public static Result notFound(String msg, Object data) {
    Result result = new Result(ResultCode.NOT_FOUND.code);
    return result;
  }

  /**
   * 500
   */
  public static Result internalServerError() {
    return internalServerError("");
  }

  /**
   * 500
   */
  public static Result internalServerError(String msg) {
    return internalServerError(msg, 0);
  }

  /**
   * 500
   */
  public static Result internalServerError(String msg, long totalCount) {
    Result result = new Result(ResultCode.INTERNAL_SERVER_ERROR.code, msg, totalCount);
    return result;
  }

}
